<template>
  <div>
    <!-- 商品内容模块 -->
    <!-- 手机 -->
    <div class="products">
      <div class="hz">
        <h2>手机</h2>
        <a href=""><div class="fr">查看更多></div></a>
      </div>
      <div class="neirong">
        <div class="mz">
          <img src="/images/long01.webp" width="235" height="630" alt="" />
        </div>
        <div id="hz1" v-for="item in phone" :key="item.id">
          <!-- <div class="p1">新品</div> -->

          <a :href="`#/detail/${item.id}`">
            <div class="hz01">
              <img v-lazy="item.s_goods_photos[0].path" alt="" />
            </div>
          </a>

          <div class="p2">{{ item.name }}</div>
          <div class="p3">{{ item.desc }}</div>
          <p class="p4">{{ item.price }}元</p>
        </div>
      </div>
    </div>
    <!-- 电视 -->
    <div class="products">
      <div class="hz">
        <h2>电视</h2>
        <a href=""> <div class="fr">查看更多></div></a>
      </div>
      <div class="neirong">
        <div class="mz">
          <img src="/images/long01.webp" width="235" height="630" alt="" />
        </div>
        <div id="hz1" v-for="item in tv" :key="item.id">
          <!-- <div class="p1">新品</div> -->

          <a :href="`#/detail/${item.id}`">
            <div class="hz01">
              <img v-lazy="item.s_goods_photos[0].path" alt="" />
            </div>
          </a>

          <div class="p2">{{ item.name }}</div>
          <div class="p3">{{ item.desc }}</div>
          <p class="p4">{{ item.price }}元</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getGoods } from "@/assets/js/request.js";
// import { mapState, mapActions, mapMutations, mapGetters } from "vuex";
export default {
  data() {
    return {
      phone: [],
      tv: [],
    };
  },
  async created() {
    //手机商品
    let res = await getGoods(5);
    this.phone = res.rows;
    this.phone = res.rows.slice(0, 8);
    // console.log(this.phone);

    //电视商品
    let res2 = await getGoods(15);
    this.tv = res2.rows;
    this.tv = res2.rows.slice(0, 8);
    // console.log(this.tv);
  },
  // computed: {
  //   ...mapState("goods", ["goods"]),
  //   ...mapGetters("goods", ["PhoneGoodsList"]),
  // },
  // created() {
  //   this.getGood();
  // },
  // methods: {
  //   ...mapActions("goods", ["getGood"]),
  //   ...mapMutations("goods", ["setGood"]),
  // },
};
</script>

<style lang="scss">
.products {
  background-color: #f5f5f5;
  .hz {
    width: 80%;
    height: 40px;
    margin: 0 auto;
    // margin-bottom: 10px;
    // margin-top: 30px;
    h2 {
      float: left;
      font-size: 20px;
      font-family: "微软雅黑";
    }
    .fr {
      float: right;
      color: black;
    }
  }
  .neirong {
    width: 1280px;
    height: 740px;
    margin: 0 auto;
    .mz {
      margin-top: 10px;
      margin-bottom: 10px;
      width: 240px;
      float: left;
      transition: 0.35s ease;
    }

    #hz1 {
      margin-top: 10px;
      width: 240px;
      height: 310px;
      background: white;
      float: left;
      margin-left: 14px;
      transition: 0.35s ease;
      overflow: hidden;
      position: relative;
    }
    .hz01 {
      margin-top: 30px;

      img {
        margin: 0 auto;
        width: 140px;
        height: 100px;
      }
    }
    .mz:hover,
    #hz1:hover {
      transform: translateY(-2px);
      box-shadow: 0px 10px 20px 5px lightgrey;
    }
  }
  .p2 {
    margin-top: 20px;
    font-size: 16px;
    font-family: "微软雅黑";
    line-height: 30px;
  }
  .p3 {
    font-size: 12px;
    color: #b0b0b0;
    line-height: 25px;
  }
  .p4 {
    font-size: 14px;
    line-height: 35px;
    color: #ff6700;
  }
}
</style>